package com.atguigu.yygh.hosp.controller.api;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.atguigu.yygh.common.result.Result;
import com.atguigu.yygh.hosp.service.DepartmentService;
import com.atguigu.yygh.hosp.service.HospitalService;
import com.atguigu.yygh.model.hosp.Department;
import com.atguigu.yygh.model.hosp.Hospital;
import com.atguigu.yygh.vo.hosp.DepartmentVo;
import com.atguigu.yygh.vo.hosp.HospitalQueryVo;

import io.swagger.annotations.ApiOperation;

/** 
* @author 作者 Your-Name: 
* @version 创建时间：2021年6月17日 上午10:40:03 
* 类说明 
*/
@RestController
@RequestMapping("/api/hosp/hospital")
public class HospApiContrller {

	@Autowired
	private HospitalService hospitalService;
	
	@Autowired
	private DepartmentService departmentService;
	
	@ApiOperation(value = "查询医院列表")
	@GetMapping("/findHospitalList/{page}/{limit}")
	public Result findHospitalList(@PathVariable(value = "page") Integer page,
                                   @PathVariable(value = "limit") Integer limit,
                                   HospitalQueryVo hospitalQueryVo){
		Page<Hospital> pageList = hospitalService.selectHospitalPage(page, limit, hospitalQueryVo);
		return Result.ok(pageList);
	}
	
	@ApiOperation(value = "根据医院名称进行模糊查询")
	@GetMapping("/findByHostname/{hostname}")
	public Result findByHostname(@PathVariable(value = "hostname") String hostname){
		List<Hospital> hospList = hospitalService.getByHostname(hostname);
		return Result.ok(hospList);
	}
	
	@ApiOperation(value = "根据医院编号获取所有科室信息")
	@GetMapping("/findDepartmentByHostcode/{hostcode}")
	public Result findDepartmentByHostcode(@PathVariable(value = "hostcode") String hostcode){
		List<DepartmentVo> deptList = departmentService.findDeptTree(hostcode);
		return Result.ok(deptList);
	}
	
	@ApiOperation(value = "根据医院编号获取医院挂号详情信息")
	@GetMapping("/findDetailByHostcode/{hostcode}")
	public Result findDetailByHostcode(@PathVariable(value = "hostcode") String hostcode){
		Map<String,Object> map = hospitalService.getHospByHostcode(hostcode);
		return Result.ok(map);
	}
}
